<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>CTF实验环境管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }

		function createInstance(id)
		{
//			$("#maskDIV").show();
//
//			var hidd=window.parent.document.getElementById("hffegeg");
//			alert(hidd);
//			showmask();
			var s = window.parent.document.getElementById("maskDIV");
			s.style.display = "block";
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneCtfEnvironment/createCtfInstance",
				data: {
					ids:id
				},
				success: function (instanceId) {
//					$("#maskDIV").hide();
//					closemask();

					//关闭遮罩
					var s = window.parent.document.getElementById("maskDIV");
					s.style.display = "none";
					window.location.href="${ctx}/scene/sceneCtfEnvironmentInstance/list";

					<%--window.open("${ctx}/scene/sceneEnvironmentInstance/list","_blank");--%>


				},
				error:function(){
					//关闭遮罩
					var s = window.parent.document.getElementById("maskDIV");
					s.style.display = "none";
					alert("生成实例失败");
				}
			});

		}

	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/scene/sceneCtfEnvironment/">CTF实验环境列表</a></li>
		<shiro:hasPermission name="scene:sceneCtfEnvironment:edit"><li><a href="${ctx}/scene/sceneCtfEnvironment/form">CTF实验环境添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="sceneCtfEnvironment" action="${ctx}/scene/sceneCtfEnvironment/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>名称：</label>
				<form:input path="ctfEnvironmentName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>ctf类型：</label>
				<form:select path="ctfType" class="input-medium">
					<form:option value="" label=""/>
					<c:choose>
						<c:when test="${isSuperAdmin=='false'}">
							<form:option value="0">${fns:getDictLabel("0",'scene_env_type',"无")}</form:option>
						</c:when>
						<c:otherwise>
							<form:options items="${fns:getDictList('scene_env_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>

						</c:otherwise>
					</c:choose>
				</form:select>
			</li>
			<li><label>标签：</label>
				<form:input path="label" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>教学实验环境名称</th>
				<th>教学实验环境类型</th>
				<th>实验时间</th>
				<th>标签</th>
				<%--<th>更新时间</th>--%>
				<%--<th>备注信息</th>--%>
				<shiro:hasPermission name="scene:sceneCtfEnvironment:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="sceneCtfEnvironment">
			<tr>
				<td><a href="${ctx}/scene/sceneCtfEnvironment/form?id=${sceneCtfEnvironment.id}">
					${sceneCtfEnvironment.ctfEnvironmentName}
				</a></td>
				<td>
					${fns:getDictLabel(sceneCtfEnvironment.ctfEnvironmentType, 'scene_env_type', '')}
				</td>
				<td>
					${fns:getDictLabel(sceneCtfEnvironment.ctfEnvironmentTime, 'scene_env_time', '')}
				</td>
				<td>
					${sceneCtfEnvironment.label}
				</td>
				<%--<td>--%>
					<%--<fmt:formatDate value="${sceneCtfEnvironment.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>--%>
				<%--</td>--%>
				<%--<td>--%>
					<%--${sceneCtfEnvironment.remarks}--%>
				<%--</td>--%>
				<shiro:hasPermission name="scene:sceneCtfEnvironment:edit"><td>
					<a href="${ctx}/scene/sceneCtfEnvironment/detail?id=${sceneCtfEnvironment.id}">详情</a>
					<c:choose>
						<c:when test="${sceneCtfEnvironment.ctfEnvironmentType=='1'&&isSuperAdmin=='false'}">
							<a style="text-decoration: none; color: grey; pointer-events: none;">修改</a>
							<a style="text-decoration: none; color: grey; pointer-events: none;">删除</a>
						</c:when>
						<c:otherwise>
							<a href="${ctx}/scene/sceneCtfEnvironment/form?id=${sceneCtfEnvironment.id}">修改</a>
							<a href="${ctx}/scene/sceneCtfEnvironment/delete?id=${sceneCtfEnvironment.id}" onclick="return confirmx('确认要删除该CTF实验环境吗？', this.href)">删除</a>
						</c:otherwise>
					</c:choose>


					<a onclick="createInstance('${sceneCtfEnvironment.id}')" target="_blank" href="javascript:void(0)">生成实例</a>

				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>